Skip to content

feat: Add asset selector dropdown#192

Merged
ritik4ever merged 2 commits into
ritik4ever:mainfrom
EmmyKay0026:feat/add_asset_selector
Apr 28, 2026
Merged

feat: Add asset selector dropdown#192
ritik4ever merged 2 commits into
ritik4ever:mainfrom
EmmyKay0026:feat/add_asset_selector

Conversation

@EmmyKay0026
Copy link
Copy Markdown
Contributor

@EmmyKay0026 EmmyKay0026 commented Apr 26, 2026

closes #162

Overview

This PR improves the user experience by replacing the free-text assetCode input in the CreateStreamForm with a dynamic dropdown. The list of available assets is now fetched directly from the backend configuration, ensuring that users can only select assets currently supported by the platform.

Changes

Backend

  • Added a new GET /api/config endpoint that exposes the ALLOWED_ASSETS configuration.

Frontend

  • Added getConfig function to the API service layer.

  • Updated CreateStreamForm to:

    - Fetch configuration on mount.
    
    • Render a dropdown when assets are successfully fetched. Implement a fallback to a text input if the API call fails or returns an empty list. Added logic to default the selection to USDC if it exists in the allowed list, or the first available asset otherwise. Summary by CodeRabbit Release Notes New Features Asset configuration is now dynamically fetched from the server, replacing hardcoded values. Asset selection UI intelligently adapts: displays a dropdown when configuration loads successfully, or falls back to manual text entry if loading fails. Improvements Asset code validation now checks against server-configured allowed assets on form load, automatically resetting invalid selections to available alternatives.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 26, 2026

@EmmyKay0026 is attempting to deploy a commit to the ritik4ever's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 26, 2026

@EmmyKay0026 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

📝 Walkthrough

Walkthrough

The pull request introduces a new backend configuration endpoint that exposes an allowed assets list, which the frontend fetches on component mount to dynamically populate an asset selector dropdown. The asset input conditionally renders as a dropdown when configuration loads successfully, or falls back to a text input if the fetch fails.

Changes

Cohort / File(s) Summary
Backend Configuration Endpoint
backend/src/index.ts
Adds new GET /api/config route that returns computed ALLOWED_ASSETS list as allowedAssets in the response body.
Frontend Service Layer
frontend/src/services/api.ts
Introduces AppConfig interface and getConfig() function to fetch configuration from the /config endpoint.
Frontend Form Component
frontend/src/components/CreateStreamForm.tsx
Refactors asset input to fetch and use dynamic allowed assets on mount. Changes from hardcoded constant to conditional rendering: displays dropdown when config loads successfully, falls back to text input on failure. Validates current asset code against fetched list and defaults to USDC if available.

Sequence Diagram

sequenceDiagram
    participant Component as CreateStreamForm
    participant Service as getConfig()
    participant Backend as GET /api/config
    participant State as Component State

    Component->>Component: Component mounts
    Component->>Service: Call getConfig()
    Service->>Backend: HTTP GET /api/config
    Backend-->>Service: {allowedAssets: string[]}
    Service-->>Component: AppConfig returned
    Component->>State: Store allowedAssets
    Component->>Component: Validate current assetCode
    alt assetCode not in allowedAssets
        Component->>State: Update assetCode to USDC or first asset
    end
    Component->>Component: Re-render with dropdown
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A config endpoint hops into view,
With assets fetched, oh what we'll do!
The dropdown springs to life so bright,
Dynamic lists, everything's right!
From backend to form, integration pure—
This feature's change, forever sure! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a dynamic asset selector dropdown sourced from backend configuration.
Linked Issues check ✅ Passed The PR fully implements all acceptance criteria: backend exposes GET /api/config with allowedAssets, frontend fetches on mount, renders select with fallback to text input, and defaults to USDC when available.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the asset selector dropdown feature: backend config endpoint, API service layer integration, and form component updates with proper fallback behavior.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend/src/components/CreateStreamForm.tsx`:
- Around line 124-147: The effect's fetchConfig closure captures a stale
values.assetCode and can overwrite a user's in-flight edit; modify the
useEffect/fetchConfig flow to add a cancellation flag and a configLoading state,
call getConfig() then setAllowedAssets only if not cancelled, read the current
assetCode from the latest state (not the captured values) before applying
defaulting, and only call setValues to default the asset when the current value
is invalid and the request isn't cancelled; also ensure you set configLoading
false and avoid setConfigFetchFailed or any state updates after
unmount/cancellation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e63f6c98-97f8-44a1-a861-657f85fa1992

📥 Commits

Reviewing files that changed from the base of the PR and between 5b50117 and ebc7c9a.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • backend/src/index.ts
  • frontend/src/components/CreateStreamForm.tsx
  • frontend/src/services/api.ts

Comment thread frontend/src/components/CreateStreamForm.tsx
@ritik4ever ritik4ever merged commit 7bd609d into ritik4ever:main Apr 28, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[wave4][frontend] Add asset selector dropdown from backend ALLOWED_ASSETS config

2 participants